# -*- coding: utf-8 -*-
"""
Created on Thu Jul 11 08:57:08 2024

@author: LoongFly
"""

# 闭运算加开运算
import cv2
import numpy as np

# img_read = cv2.imread("A3_Morphology\\photo\\jjj.png",cv2.IMREAD_UNCHANGED)    # 读取图像
# img_read = cv2.imread(A3_Morphology\\photo\\zimu.png",cv2.IMREAD_UNCHANGED)    # 读取图像
img_read = cv2.imread("A3_Morphology\\photo\\LenaRGB.bmp",cv2.IMREAD_UNCHANGED)    # 读取图像

kernel = np.ones((5, 5),np.uint8)   # 创建一个5*5的卷积核
kernel2 = np.ones((7, 7),np.uint8)
# 图像处理
img_result = cv2.morphologyEx(img_read, cv2.MORPH_GRADIENT, kernel)


# 图像显示
cv2.imshow("Original", img_read)    # 原始 图像
cv2.imshow("Gradient", img_result)  # 梯度运算 图像


cv2.waitKey()
cv2.destroyAllWindows()